﻿using IdentityServer4.Validation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;

namespace User.Identity.Authentication
{
    public class ResourceOwnerPasswordValidator
        : IResourceOwnerPasswordValidator
    {
        public Task ValidateAsync(ResourceOwnerPasswordValidationContext context)
        {
            if (context.UserName.Equals("gainorloss") && context.Password.Equals("p@ssw0rd"))
            {
                context.Result = new GrantValidationResult("1","custom",claims:new List<Claim>() { new Claim("id","1"),new Claim("name", "gainorloss"),new Claim("age", "25") });
            }
            return Task.CompletedTask;
        }

    }
}
